interface Person {
    firstName: string
    lastName: string
}

// TypeScript里的类只是JavaScript里常用的基于原型面向对象编程的简写
class Student {
    fullName: string
    // 在构造函数的参数上使用public等同于创建了同名的成员变量
    constructor(public firstName, public middleInitial, public lastName) {
        this.fullName = firstName + " " + middleInitial + " " + lastName
    }
}

function greeter(person: Person) {
    return "Hello, " + person.firstName + " " + person.lastName;
}

// 只要保证包含了接口要求的结构就可以，而不必明确地使用 implements语句
let user = new Student("Jane", "M.", "User")

document.body.innerHTML = greeter(user);

